#!/bin/sh
#
# Small shell script to show how to start/stop Atomojo using jsvc
#
# Adapt the following lines to your configuration
JAVA_HOME=/usr/lib64/jvm/java-1.5.0-sun-1.5.0_update10
AUTHSERVICE_HOME=/home/auth/current
AUTHSERVICE_DBDIR=/home/auth/db
DAEMON_HOME=$AUTHSERVICE_HOME/jsvc
AUTHSERVICE_USER=auth

# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/auth.pid

AUTHSERVICE_OPTS=""
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$AUTHSERVICE_HOME/jsvc/commons-daemon.jar:\
$AUTHSERVICE_HOME/authservice.jar

case "$1" in
  start)
    #
    # Start Atomojo Auth Service
    #
    $DAEMON_HOME/jsvc \
    -user $AUTHSERVICE_USER \
    -home $JAVA_HOME \
    -Djava.io.tmpdir=$TMP_DIR \
    -wait 10 \
    -pidfile $PID_FILE \
    -outfile $AUTHSERVICE_HOME/server.out \
    -errfile '&1' \
    $AUTHSERVICE_OPTS \
    -cp $CLASSPATH \
    org.atomojo.auth.service.Daemon \
    $AUTHSERVICE_DBDIR
    #
    # To get a verbose JVM
    #-verbose \
    # To get a debug of jsvc.
    #-debug \
    exit $?
    ;;

  stop)
    #
    # Stop Atomojo Auth Service
    #
    $DAEMON_HOME/jsvc \
    -stop \
    -pidfile $PID_FILE \
    org.atomojo.auth.service.Daemon
    exit $?
    ;;

  *)
    echo "Usage authservice.sh start/stop"
    exit 1;;
esac
